home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5787 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.7 KB  |  79 lines

  1. Newsgroups: comp.sys.mac.programmer.codewarrior,comp.lang.c++
  2. Path: info.physics.utoronto.ca!news
  3. From: Andrew Datars <datars@tiger.physics.utoronto.ca>
  4. Subject: Re: using a template parameter as a qualifier -- legal or not?
  5. Message-ID: <3117C2B0.41C6@tiger.physics.utoronto.ca>
  6. Nntp-Posting-Host: husky.physics.utoronto.ca
  7. Sender: news@info.physics.utoronto.ca (System Administrator)
  8. Mime-Version: 1.0
  9. X-Mailer: Mozilla 2.0b6a (X11; I; IRIX64 6.0.1 IP26)
  10. Content-Type: text/plain; charset=us-ascii
  11. Organization: Dept. of Physics, Univ. of Toronto
  12. Date: Tue, 6 Feb 1996 21:05:52 GMT
  13. References: <rshapiro-0602961258310001@esb.bbn.com>
  14. Content-Transfer-Encoding: 7bit
  15.  
  16. R Shapiro wrote:
  17. > I'd like to use the formal argument to a template as the qualifier of a
  18. > qualified typename within the template. This doesn't work in CodeWarrior
  19. > 8, it does work in VC++ 4.0, and I can't tell from ARM whether or not it
  20. > *should* work.
  21. > Here's a more specific example:
  22. > template <class OBJECT>
  23. > class OrderedCollection {
  24. >    typedef void (OBJECT::*memberMapper)(void);
  25. > .
  26. > .
  27. > .
  28. > };
  29. > I would like the typedef 'memberMapper' to refer to pointers to member
  30. > functions (of no arguments and returning no value) of whatever class is
  31. > specified in a given instantiation of the template.
  32. > For instance, if X and Y are classes, I would expect memberMapper in
  33. > OrderedCollection<X> to be:
  34. >   void (X::*memberMapper)(void)
  35. > and memberMapper in OrderedCollection<Y> to be:
  36. >    void (Y::*memberMapper)(void)
  37. > Should this work or not? If not, why not? If so -- this is a bug in CW8.
  38. > --
  39. > rs/rshapiro@bbn.com
  40.  
  41. I have in my code something like this ...
  42.  
  43. typedef double (INTERPOLATE_DOS::*TInterpolateFunction)(double);
  44.  
  45. where INTERPOLATE_DOS is a parameter to the template.
  46.  
  47. However, I would not be that surprised if CodeWarrior doesn't
  48. work with it. I have a little anecdote. I started trying
  49. to use pointers to member functions of a parametrized class
  50. about 3 years ago. At the time few compilers really had templates
  51. working very well. With a little snippet of code I could break
  52. many compilers. I can still use this to break certain
  53. compilers in certain instances (where the pointer to member function
  54. is to an overloaded function). I have not used CodeWarrior. So
  55. I can't really comment on your question directly. I know that
  56. for most compilers the above DOES work. But I have had the technique
  57. actually cause the SGI compiler to crash, as well as evoke
  58. all kinds of wacky error messages from cfront, and g++, and Borland
  59. C++ 4.5.
  60.  
  61. Hope that helps.
  62.  
  63.  
  64. Andrew
  65. -- 
  66. Andrew Datars    (datars@tiger.physics.utoronto.ca)
  67. Quantum Transport/General Computer Helper             phone:(416)978-6185
  68. Dept. of Physics, Univ. of Toronto                 fax:  (416)978-2537
  69.